package com.modules.system.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.modules.system.dao.SysRoleMenuDao;
import com.modules.system.service.SysRoleMenuService;
import java.util.List;


/**
 * 角色与菜单对应关系
 * 
 */
@Service("sysRoleMenuService")
public class SysRoleMenuServiceImpl implements SysRoleMenuService {
	@Autowired
	private SysRoleMenuDao sysRoleMenuDao;

	@Override
	@Transactional
	public void saveOrUpdate(Long roleId, List<Long> menuIdList) {
		//先删除角色与菜单关系
		sysRoleMenuDao.deleteByRoleId(roleId);

		if(menuIdList.size() == 0){
			return ;
		}
		sysRoleMenuDao.saveListByRoleId(roleId, menuIdList);
	}

	@Override
	public List<Long> getMenuIdList(Long roleId) {
		return sysRoleMenuDao.getMenuIdList(roleId);
	}

}
